package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 *
 * @author zhough
 * @email zhough@gmail.com
 * @date 2024-01-22 20:28:15
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

    Long selectStockInfo(@Param("skuId") Long skuId);

    List<Long> queryWareIdsBySkuIdAndSkuNum(@Param("skuId") Long skuId, @Param("count") Integer count);

    Boolean tryLockSku(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("count") Integer count);

    boolean unlockStockBySkuIdAndWareId(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);
}
